import RequestBase from '@/utils/request';
import config from '@/config';

const baseRequest = new RequestBase(config.education);
// 培训记录列表
export const reqGetTrainingRecordList = (query) => {
	return baseRequest.get('/training-plan/record/list', query);
};
// 在线培训列表
export const reqGetOnlineTrainingList = (query) => {
	return baseRequest.get('/online-training/list', query);
};

// 线上培训详情
export const reqPostTrainingTasks = (query) => {
	return baseRequest.post(`/online-training`, query);
};

// 线上培训详情
export const reqGetTrainingTasksDetail = (query) => {
	return baseRequest.get(`/online-training/detail`, query);
};

// 存档
export const reqPostTrainingSave = (data) => {
	return baseRequest.post(`/online-training`, data);
};

const baseUrlRequest = new RequestBase(config.baseUrl);
const basicRequest = new RequestBase(config.basicInfoUrl);

// 试题类型
export const getExaminationTypeList = (category) => {
	return baseRequest.get(`/resource/category/${category}/list`);
};

// 树形结构试题类型
export const getExaminationTypeListByTree = (category) => {
	return baseRequest.get(`/resource/category/${category}/tree-count`);
};

// 根据类型获取试题列表
export const getExamListByType = (typeId) => {
	return baseRequest.get(`/resource/question/list/category/${typeId}`)
}

// 获取培训列表
export const getTrainingList = (data) => {
	return baseRequest.get('/plan/train-task/todo-list', data)
}

// 培训记录列表
export const getTrainingRecordList = (data) => {
	return baseRequest.get('/plan/train-task/record-list', data)
}

// 培训课件
export const getTrainingCourse = (taskId) => {
	return baseRequest.get(`/plan/train-task/${taskId}/start`)
}

// 签到查询
export const signDetail = (id) => {
	return baseRequest.get(`/edu/train/plan/detail/sign/${id}`)
}

// 签到
export const signTrain = (id) => {
	return baseRequest.post(`/edu/train/plan/sign/${id}`)
}

/**
 * 获取评分配置
 */
export function reqDetailEvaluateList(query) {
	return baseRequest.get(`/plan/evaluate/config`, query);
}

// 获取教师评价详情
export const getEvaluateDetail = (taskId) => {
	return baseRequest.get(`/plan/train-task/${taskId}/coursewares?enableHasTeacher=true`)
}

// 提交评价
export const submitEvaluate = (taskId, data) => {
	return baseRequest.put(`/plan/evaluate/record?taskId=${taskId}`, data)
}


// 保存课件学习时长
export const postCourseLearnedTime = (taskId, data) => {
	return baseRequest.post(`/plan/train-task/${taskId}/learn`, data)
}
